﻿Imports kplusEntity.KPLUS.Entity
Imports kplusCommon.KPLUS.Common
Imports kplusLogic.KPLUS.Logic

Partial Public Class frmLimiteGlobalMnt
    Inherits System.Web.UI.Page
    Private ruta As String
    Private strConexion As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ConfigurarScript()
    End Sub
    Private Sub ConfigurarScript()
        Dim strPeriodoMes As String
        strPeriodoMes = lblPeriodo.Text
        ruta = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath
        imbHistorico.Attributes.Add("onclick", "VerHistoricoLimiteGlobal('" + ruta + "','" + strPeriodoMes + "');")

    End Sub

    Protected Sub imbGuardar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imbGuardar.Click
        Dim objELimiteGlobal As New ELimiteGlobal
        Dim objELogMantenimiento As New ELogMantenimiento
        Dim objLLimiteGlobal As New LLimiteGlobal
        Dim strUserId As String = Request.Cookies("UserId").Value
        strConexion = ConfigurationManager.ConnectionStrings("ConnectionStringOracle").ConnectionString

        With objELimiteGlobal
            .CodUsrRegistro = strUserId
            .FecActualizacionTabla = Date.Now
            .FecRegistro = Date.Now
            .FlgActivo = True
            .NumVersion = 1
            .PeriodoMes = lblPeriodo.Text
            .PctLimiteGlobal = txtLimiteGlobal.Text
            .TipoOperacion = Constante.TipoOperacion.R
        End With

        With objELogMantenimiento
            .CodUsrRegistro = strUserId
            .FecActualizacionTabla = Date.Now
            .FecRegistro = Date.Now
            .FlgActivo = True
            .NumVersion = 1
            .PeriodoMes = lblPeriodo.Text
            .TipoOperacion = Constante.TipoOperacion.R
            .CodMantenimiento = ""
            .DesMantenimiento = ""
            .DESCOMENTARIO = ""
            .NumAnhio = Date.Now.Year
        End With

        objLLimiteGlobal.fInsertarLimiteGlobal(strConexion, objELimiteGlobal, objELogMantenimiento)

    End Sub
End Class